<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>商城运营管理后台</title>
<style type="text/css">
#container{width:1120px;align:center;}
label,input,td,select,form{ padding:0; margin:0;}
.container{ font:12px/1.5 arial sans-serif;}
th input{ font-size:11px; position:relative; top:2px;}
table{ border:1px solid #81cef7;table-layout: fixed; border-collapse:collapse;margin-top:10px;max-width:1015px; text-align:center;font-size:12px;}
th{ background:#b6e0f7;}
td,th{  border:1px solid #81cef7; padding:0; word-wrap:break-word; word-break:break-all;}
table .col_shop{ width:90px;}
table img{border:0;padding:0;}
tr:hover{background-color:#f0f7f9;}
.picLink img{width:45px;height:35px;}
.odd{ background:#e7f1f7;}
#property_select_dialog,#add_id_dialog,#edit_item,#syn_cb_info{border:2px solid #8db2e3;padding:0;position:absolute;background:#fff;}
#add_id_dialog h3,#edit_item h3,#property_select_dialog h3,#syn_cb_info h3{cursor:move;background-color:#b6e0f7;margin:0;height:30px;padding:10px 0 0 10px;#color:red;}
.hidden_state {display:none;}
.show_state{display:block;left:150px;top:80px;width:550px;}
.show_state_edit{display:block;width:500px;}
.sy_show{display:block;width:220px;height:100px;left:330px;top:80px;}
#property_select_dialog{width:510px;}
#add_id_dialog input{width:120px;}
.close_icon{position:absolute;top:4px;right:4px;}
#edit_item p{margin:0;}
#edit_item{width:500px;}
#edit_item label{display:table-cell;width:120px;float:left;}
#edit_item input{width:120px;}
.error{color:red;}
#property_select_dialog label{margin-right:10px;width:80px;}
.dialog_content{margin:15px 25px;}
.tr_hide{display:none;}
#msg{float:right;background:#00ffff;}
.non_visible{visibility:hidden;}
.visible{visibility:visiable;}
</style>
</head>
<body>
<script type="text/javascript" src="http://localhost/jiajia/nanbeihuo/js/base/qqshop_1.0.js"></script>
<script type="text/javascript" src="http://localhost/jiajia/nanbeihuo/js/base/shop_opr_1.0.js"></script>
<script type="text/javascript">
var g_brand_tree = null;
var g_category_tree = null;
function addChildToForm(name, value, form)
{
    if ( typeof name != "string" || typeof value != "string" || typeof form == "undefined" )
    {
        return false;
    }
    var input = document.createElement("input");
    input.name = name;
    input.value = value;
    form.appendChild(input);
}
function changeBrandSelect(selectedIndex)
{
    if (typeof selectedIndex == "undefined")
    {
        return false;
    }

    var obj_select_b = $O("goods_category_b");
    var category_id  = obj_select_b.options[selectedIndex].value;
    var arr_brand = g_brand_tree[category_id];
    
    if (typeof arr_brand == "undefined")
    {
        return false;
    }
    var obj_select_brand = $O("goods_brand");
    select_removeAllOption(obj_select_brand);
    for (var i = 0; i < arr_brand.length; ++i)
    {
        select_addOption(obj_select_brand, arr_brand[i].brandName, arr_brand[i].brandId);
    }
    //alert(g_json_data[selectedIndex-1].self.category_name);
}
function changeSubCategorySelect(selectedIndex)
{
    if (typeof selectedIndex == "undefined")
    {
        return false;
    }
    var arr_category = new Array();
    for (var i = 0; i < g_category_tree[selectedIndex-1].child.length; ++i)
    {
        getSubCategory(g_category_tree[selectedIndex-1].child[i], arr_category);
    }

    var obj_select_brand = $O("goods_brand");
    select_removeAllOption(obj_select_brand);
    var obj_select_b = $O("goods_category_b");
    select_removeAllOption(obj_select_b);
    for (var i = 0; i < arr_category.length; ++i)
    {
        select_addOption(obj_select_b, arr_category[i].category_name, arr_category[i].category_id);
    }
    //alert(g_json_data[selectedIndex-1].self.category_name);
}

function select_removeAllOption(obj_select)
{
    if (typeof obj_select == "undefined")
    {
        return false;
    }
    while (obj_select.options.length > 1)
    {
        obj_select.remove(1);
    }
    return true;
}
function getSubCategory(category, arr_category)
{
    if (typeof category == "undefined" || typeof category.self == "undefined")
    {
        return false;
    }
    arr_category.push(category.self);
    if (category.child.length == 0)
    {
        return false;
    }
    else
    {
        for (var i = 0; i < category.child.length; ++i)
        {
            arr_category.push(category.child[i]);
        }
    }
}
function select_addOption(objSelectNow,txt,val){var objOption = parent.document.createElement("OPTION");objOption.text= txt;objOption.value=val;objSelectNow.options.add(objOption);}
function uploadGoodsWeb()
{
    var obj_form = $O("goods_form");
    obj_form.action = "http://localhost/jiajia/nanbeihuo/index.php?controller=goods&action=uploadgoodsweb";
    obj_form.method = "post";
    addChildToForm("callback", "uploadGoodsWebCallback", obj_form);
    var obj_select_b = $O("goods_category_b");
    var obj_select_a = $O("goods_category_a");
    if ( obj_select_b.options[obj_select_b.selectedIndex].value == "select_category" )
    {
        var category = obj_select_a.options[obj_select_a.selectedIndex].value;
    }
    else
    {
        var category = obj_select_b.options[obj_select_b.selectedIndex].value;
    }
    addChildToForm("category_id", category, obj_form);
    var obj_select_brand = $O("goods_brand");
    if (obj_select_brand.options[obj_select_brand.selectedIndex].value == "select_brand")
    {
        return false;
    }
    else
    {
        var brand = obj_select_brand.options[obj_select_brand.selectedIndex].value;
    }
    addChildToForm("brand_id", brand, obj_form);
    obj_form.submit();
    return false;
}
function uploadGoodsXLS()
{
    var obj_form = $O("goods_xls_form");
    obj_form.action = "http://localhost/jiajia/nanbeihuo/index.php?controller=goods&action=uploadgoodsxls";
    obj_form.method = "post";
    addChildToForm("callback", "uploadGoodsXLSCallback", obj_form);
    obj_form.submit();
}
</script>
<div id="container">
	<div id="msg"></div>
	<div id="menu">
			<button id="select_all" onclick="selectAll();return false;" title="全选">全选</button>
			<button id="cancel_all" onclick="cancelAll();return false;" title="取消">取消</button>
			<!--<button id="build" title="保存数据">保存数据</button>-->
			<button  id="export_xls" onclick="exportXls();return false;" href="return false;" title="导出Excel">导出Excel</button>
			<button  id="refresh" onclick="refreshData();return false;" href="#" title="刷新数据">刷新数据</button>
			<button id="syn" onclick="reSort('week');return false;" href="return false;" title="周销量排序">周销量排序</button>
			<button id="save" onclick="reSort('month');return false;" href="return false;" title="月销量排序">月销量排序</button>
			<button id="pv_btn" onclick="reSort('pv');return false;" href="return false;" title="关注度排序">关注度排序</button>
	</div><!--菜单结束-->
    <br/>
	<select id="goods_category_a" onchange="if (this.selectedIndex) changeSubCategorySelect(this.selectedIndex);"><option value="root_category" id="root">root</option></select><select id="goods_category_b" onchange="if (this.selectedIndex) changeBrandSelect(this.selectedIndex);"><option value="select_category" id="select_category">请选择所属类目</option></select><select id="goods_brand" ><option value="select_brand" id="select_brand">请选择所属品牌</option></select>
    <br/>
	<!--显示商品信息table-->
	<table id="item_table">
		<colgroup>
			<col class="sellerUin_col"  />
			<col class="sellerCredit_col" />
			<col class="itemCode_col" />
			<col class="picLink_col" />
			<col class="itemName_col" />
			<col class="shortName_col" />
			<col class="stockCount_col" />
			<col class="soldTotalCount_col" />
			<col class="sellerPayFreight_col" />
			<col class="marketPrice_col" />
			<col class="itemPrice_col" />
			<col class="qqvipDiscount_col" />
			<col class="size_col" />
			<col class="createTime_col" />
			<col class="stateDesc_col" />
			<col class="lastToSaleTime_col" />
			<col class="operator" />
		</colgroup>
		<thead>
			<tr>
				<th style="width:20px" class="sellerUin_th">
					<label for="sellerUin_ck">选择</label><br/>
				</th>
				<th style="width:20px" class="sellerUin_th">
					<label for="sellerUin_ck">排名</label><br/>
				</th>
				<th style="width:80px" class="itemCode_th">
					<label for="itemCode_ck">商品ID</label><br/>
				</th>
				<th style="width:45px" class="picLink_th">
					<label for="picLink_ck">在架商品ID</label><br/>
				</th>
				<th style="width:120px" class="sellerUin_th">
					<label for="sellerUin_ck">商品图片</label><br/>
				</th>
				<th style="width:80px" class="sellerCredit_th">
					<label for="sellerCredit_ck">类目</label><br/>
				</th>
				<th style="width:90px" class="itemName_th">
					<label for="itemName_ck">商品名</label><br/>
				</th>
				<th style="width:60px" class="marketPrice_th">
					<label for="marketPrice_ck">市场价</label><br/>
				</th>
				<th style="width:60px" class="itemPrice_th">
					<label for="itemPrice_ck">商城价</label><br/>
				</th>
				<th style="width:60px" class="qqvipDiscount_th">
					<label for="qqvipDiscount_ck">会员价</label><br/>
				</th>
				<th style="width:80px" class="size_th">
					<label for="size_ck">库存量</label><br/>
				</th>
				<th style="width:90px">关注量<br></th>
				<th style="width:90px">收藏量<br></th>
				<th style="width:50px" class="stockCount_th">
					<label for="stockCount_ck">剩余件数</label><br/>
				</th>
				<th style="width:60px" class="sellerPayFreight_th">
					<label for="sellerPayFreight_ck">卖家承担运费？</label><br/>
				</th>
				<th style="width:80px" class="createTime_th">
					<label for="createTime_ck">发布时间</label><br/>
				</th>
				<th style="width:80px" class="stateDesc_th">
					<label for="stateDesc_ck">状态描述</label><br/>
				</th>
				<th style="width:80px" class="lastToSaleTime_th">
					<label for="lastToSaleTime_ck">上架日期</label><br/>
				</th>
			</tr>
		</thead>
		<tbody id="item_table_body">
		</tbody>
	</table><!--显示商品信息table结束-->
	

	<!--选择显示属性对话框-->
	<div id="property_select_dialog" class="hidden_state">
		<h3>选取要显示的商品属性</h3>
		<img src="img/close_small.gif" alt="关闭按钮" title="关闭" class ="close_icon" id="property_select_dialog_close" />
		<div class="dialog_content">
			<p class="checks_properties"></p>
			<input type="button" value="确定" id="hidden_property"/>
			<input type="button" value="取消" id="cancel_hidden_property" />
			<br />
		</div>
	</div><!--选择显示属性对话框结束-->

	<!--添加商品ID-->
	<div id="add_id_dialog" class="hidden_state">
		<h3>添加商品ID</h3>
		<img src="img/close_small.gif" alt="关闭按钮" title="关闭" class ="close_icon" id="add_id_dialog_close"/>
		 <div class="dialog_content">
			<p>ID之间用逗号或空格分隔(重复ID只会被添加一次)</p>
			<div id="add_id_form">
				<p id="add_id_msg"></p>
				<form action="./php/getMessage.php" method="get"  id="form_add_id" onsubmit="return AddID.addIdCheck(this)">
					<textarea cols="60" rows="8" id="add_id_area" name="ids"></textarea><br/>
					<input type="submit" value="添加" />
					<input type="button" value="取消" id="add_id_cancel" />
				</form>
			</div><!--add_id_form结束-->
		</div>
	</div><!--添加商品ID对话框结束-->
	


	<!--修改商品信息对话框-->
	<div id="edit_item" class="hidden_state">
		<h3>修改商品信息</h3>
		<img src="img/close_small.gif" alt="关闭按钮" title="关闭" class ="close_icon" id="edit_item_close" />
		 <div class="dialog_content">
			<form action="" onsubmit="return Edit.editSbumit()">
				<label>店家ID:</label><input type="text" name="sellerUin" disabled="disabled" /><br />
				<label>卖家信用:</label><input type="text" name="sellerCredit" disabled="disabled" /><br />
				<label>商品ID:</label><input type="text" name="itemCode" disabled="disabled" /><br />
				<label>商品图片:</label><input type="text" name="picLink" /><br />
				<label>长名:</label><input type="text" name="itemName" /><br />
				<label>短名:</label><input type="text" name="shortName" /><span class="shortName_msg error">&nbsp;</span><br />
				<label>剩余件数:</label><input type="text" name="stockCount" /><span class="stockCount_msg error">&nbsp;</span><br />
				<label>已售件数:</label><input type="text" name="soldTotalCount" /><span class="soldTotalCount_msg error">&nbsp;</span><br />
				<label>卖家承担运费</label><select name="sellerPayFreight" id="sellerPayFreight_select"><option value="1">是</option><option value="0">否</option></select><br />
				<label>市场价:</label><input type="text" name="marketPrice" /><span class="marketPrice_msg error">&nbsp;</span><br />
				<label>商城价:</label><input type="text" name="itemPrice" /><span class="itemPrice_msg error">&nbsp;</span><br />
				<label>会员折扣:</label><input type="text" name="qqvipDiscount" /><span class="qqvipDiscount_msg error">&nbsp;</span><br />
				<label>尺寸/大小:</label><input type="text" name="size" /><br />
				<label>发布时间:</label><input type="text" name="createTime" /><br />
				<label>状态描述:</label><input type="text" name="stateDesc" /><br />
				<label>上架日期:</label><input type="text" name="lastToSaleTime" /><span class="lastToSaleTime_eg"></span><br />
				<input type="submit" value="保存修改" id="edit_submit"/><input type="button" value="取消" id="edit_cancel"/><br />
			</form>
		</div>
	</div><!--修改商品信息对话框结束-->
	
	<!--同步数据-->
	<div id="syn_cb_info" class="hidden_state">
		<h3>同步数据</h3>
		<img src="img/close_small.gif" alt="关闭按钮" title="关闭" class ="close_icon non_visible" id="syn_cb_close" />
		<div class="dialog_content">
			<div id="syn_cb_msg">&nbsp;</div>
			<a href="" title="预览" class = "non_visible">预览</a>
		</div>
	</div>
	
<div style="display:none">
<form id="submit_form" name="submit_form" action="http://localhost/jiajia/nanbeihuo/index.php?controller=brand&action=exportbrandgoodsxls" method="POST" target="cbFrame">
</form>
</div>
</div><!--整个页面内容结束-->


<script type="text/javascript">
//<![CDATA[
	var item_attr=["sellerUin","sellerCredit","itemCode",
	"picLink","itemName","shortName","stockCount","soldTotalCount",
	"sellerPayFreight","marketPrice","itemPrice","qqvipDiscount","size",
	"createTime","stateDesc","lastToSaleTime"] ;
	var item_name=["店家ID","卖家信用","商品ID","商品图片","长名","短名","剩余件数","已售件数","卖家承担运费？","市场价","商城价","会员折扣","尺寸/大小","发布时间","状态描述","上架日期","选中"];
//]]>
</script>
<script type="text/javascript">
function $O(o){return document.getElementById(o);}
var g_json_data;
var g_checkbox = Array();
function selectItem(itemCode)
{
	if (g_checkbox[itemCode])
	{
		g_checkbox[itemCode] = (g_checkbox[itemCode] + 1) % 2;
	}
	else
	{
		g_checkbox[itemCode] = 1;
	}
}

function exportXls()
{
	var xls_json = new Array();
	var xls_item_list = "";
	//xls_json.items = Array();
	for (var key in g_checkbox)
	{	
		if ( g_checkbox[key] == 1 )
		{
			xls_item_list += key + "|";
			//xls_json.push(g_json_data.item_table.hot_sale_items[key]);
		}
	}
    var obj_select_b = $O("goods_category_b");
    var obj_select_a = $O("goods_category_a");
    if ( obj_select_b.options[obj_select_b.selectedIndex].value == "select_category" )
    {
        var category = obj_select_a.options[obj_select_a.selectedIndex].value;
    }
    else
    {
        var category = obj_select_b.options[obj_select_b.selectedIndex].value;
    }

    var obj_select_brand = $O("goods_brand");
    if (obj_select_brand.options[obj_select_brand.selectedIndex].value == "select_brand")
    {
        return false;
    }
    else
    {
        var brand = obj_select_brand.options[obj_select_brand.selectedIndex].value;
    }
	xls_item_list = xls_item_list.substring(0, xls_item_list.length - 1);
	var obj_form  = $O("submit_form");
	obj_form.innerHTML = "";
	obj_form.action = "http://localhost/jiajia/nanbeihuo/index.php?controller=brand&action=exportbrandgoodsxls";
	addChildToForm("callback", "exportXlsCallback", obj_form);
	addChildToForm("xls_item_list", xls_item_list, obj_form);
	addChildToForm("category_id", category, obj_form);
	addChildToForm("brand_id", brand, obj_form);
	addChildToForm("brand_name", g_json_data.brand.brand_name, obj_form);
	addChildToForm("xls_item_list", xls_item_list, obj_form);
	obj_form.submit();
	
	//json2Excel(xls_json);
}

function exportXlsCallback()
{
}

function refreshDataCallback()
{
	alert("刷新数据成功！");
}
function refreshData()
{
    var obj_select_b = $O("goods_category_b");
    var obj_select_a = $O("goods_category_a");
    if ( obj_select_b.options[obj_select_b.selectedIndex].value == "select_category" )
    {
        var category = obj_select_a.options[obj_select_a.selectedIndex].value;
    }
    else
    {
        var category = obj_select_b.options[obj_select_b.selectedIndex].value;
    }

    var obj_select_brand = $O("goods_brand");
    if (obj_select_brand.options[obj_select_brand.selectedIndex].value == "select_brand")
    {
        return false;
    }
    else
    {
        var brand = obj_select_brand.options[obj_select_brand.selectedIndex].value;
    }
    var json_url = "http://localhost/jiajia/nanbeihuo/json/export/xls/" + category + "/" + brand + ".js";
    var jsLoader = new QZFL.JsLoader();
    jsLoader.load(json_url, document, "utf-8");

    return false;
}

function json2Excel(json_data)
{
	var   oXL   =   new   ActiveXObject("Excel.Application");
	oXL.Visible =   true;   
	var   oWB   =   oXL.Workbooks.Add();   
    var  oSheet =   oWB.ActiveSheet; 
	
	var iRow = 1;
	var iCol;
	for (var index in json_data)
	{
		if (typeof json_data[index] == "object")
		{
			iCol = 1;
			var json_row = json_data[index];
			for (var key in json_row)
			{
				if (typeof json_row[key] != "undefined")
				{
					oSheet.Cells(iRow,iCol).value = json_row[key];
					++iCol;
				}
			}
			++iRow;
		}
	}
	oXL.Visible = true;
}

function fillTable(json_data)
{
	if ( typeof json_data != "object" || typeof json_data.goods == "undefined" )
	{
		return false;
	}
	var obj_div   = document.createElement("div");
	var obj_table = document.getElementById("item_table_body"); 
    
    g_json_data = json_data;
    var json_table_data = json_data.goods;
	i = 0;
	for ( var key in json_table_data )
	{
		var s_html = "<table><tr>";
		var tr = json_table_data[key];
        var picLink = tr.small_img_urls.split("\n")[0];
		s_html += "<td class='sellerUin' title=''><input type='checkbox' name='xls' onclick=\"selectItem('"+i+"');\"></td>";
		s_html += "<td class=\"sellerCredit\" title=\""+(i+1)+"\">"+(i+1)+"</td>";
		s_html += "<td class=\"itemCode\" title=\""+tr.goods_id+"\"><a href=\"http:\/\/auction1.paipai.com\/"+tr.goods_id+"\" title=\""+tr.goods_id+"\" target=\"_blank\">"+tr.goods_id+"</a></td>";
		s_html += "<td class=\"sellerUin\" title=\""+tr.goods_onshelf_id+"\">"+tr.goods_onshelf_id+"</td>";
        s_html += "<td class=\"picLink\" title=\""+picLink+"\"><img alt=\"\" src=\""+picLink+"\" title=\""+picLink+"\"/></td>";
		s_html += "<td class=\"sellerCredit\" title=\"\">"+"</td>";
		s_html += "<td class=\"itemName\" title=\""+tr.goods_name+"\">"+tr.goods_name+"</td>";
		s_html += "<td class=\"marketPrice\" title=\""+tr.market_price+"\">"+tr.market_price+"</td>";
		s_html += "<td class=\"itemPrice\" title=\""+tr.mall_price+"\">"+tr.mall_price+"</td>";
		s_html += "<td class=\"qqvipDiscount\">"+tr.vip_price+"</td>";
		s_html += "<td>"+tr.stock+"</td>";
		s_html += "<td class=\"stockCount\">"+tr.visitCount+"</td>";
		s_html += "<td class=\"stockCount\">"+tr.collectionCount+"</td>";
		s_html += "<td class=\"soldTotalCount\">"+tr.stockCount+"</td>";
		if ( tr.mailPrice == 0 )
		{
			s_html += "<td class=\"size\">是</td>";
		}
		else
		{
			s_html += "<td class=\"size\">否</td>";
		}
		s_html += "<td class=\"createTime\">"+tr.createTime+"</td>";
		s_html += "<td class=\"stateDesc\" ></td>";
		s_html += "<td class=\"lastToSaleTime\">"+tr.lastToSaleTime+"</td>";
		s_html += "</tr></table>";
		obj_div.innerHTML = s_html;
		var obj_tr = obj_div.getElementsByTagName("tr")[0];
		obj_table.appendChild(obj_tr);
		++i;
	}
}

function localFillAct(json, json_name)
{
	return false;
}

function selectAll()
{
	var json_data = g_json_data.goods;
	for ( var key in json_data )
	{
		g_checkbox[key] = 1;
	}
	
	var obj_table = document.getElementById("item_table_body"); 
	var obj_tr = obj_table.getElementsByTagName("tr"); 
	for ( var i = 0; i < obj_tr.length; ++i )
	{
		obj_tr[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked = true; 
	}
	return false;
}

function cancelAll()
{
	var json_data = g_json_data.goods;
	for ( var key in json_data )
	{
		g_checkbox[key] = 0;
	}
	
	var obj_table = document.getElementById("item_table_body"); 
	var obj_tr = obj_table.getElementsByTagName("tr"); 
	for ( var i = 0; i < obj_tr.length; ++i )
	{
		obj_tr[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked = false; 
	}
	return false;
}

function hot_sale_callback (json_data)
{
	g_json_data = json_data;
	json_table_data = json_data.item_table.hot_sale_items;
	fillTable( json_table_data );
	//fillAct(json_data, "hot_sale.html");
}
</script>
<script type="text/javascript">
function fillAct(json_data, json_name)
{
    if (typeof json_data == "undefined" || typeof json_name != "string")
    {
        return false;
    }
    if (json_name.match(/category_tree/))
    {
        g_category_tree = json_data;
    }
    else if (json_name.match(/brand_tree/))
    {
        g_brand_tree = json_data;
    }
    else
    {
        return false;
    }
    var len = json_data.length;
    var obj_select_a = $O("goods_category_a");
    for ( var i = 0; i < len; ++i )
    {
        select_addOption(obj_select_a, json_data[i].self.category_name, json_data[i].self.category_id );
    }
}
var jsLoader = new QZFL.JsLoader();
jsLoader.load("http://localhost/jiajia/nanbeihuo/json/json_brand_tree.js", document, "utf-8");
</script>
<script type="text/javascript" src="http://localhost/jiajia/nanbeihuo/json/json_category_tree.js"></script>
</body>
</html>
这里放各个二级JS管理后台

